local skynet = require "skynet"
local filelog = require "filelog"
local msghelper = require "agenthelper"
local processstate = require "processstate"
local playerdatadao = require "playerdatadao"
local msgproxy = require "msgproxy"

require "enum"

local processing = processstate:new({timeout=4})
local GetRankList = {}

function  GetRankList.process(session, source, fd, request)
    local responsemsg = {
        errcode = EErrCode.ERR_SUCCESS,
    }


    local server = msghelper:get_server()
    --检查当前登陆状态
	if not msghelper:is_login_success() then
		filelog.sys_error("GetRankList.process invalid server state", server.state)
		responsemsg.errcode = EErrCode.ERR_INVALID_REQUEST
		responsemsg.errcodedes = "无效的请求!"
		msghelper:send_resmsgto_client(fd, "RankListRes", responsemsg)		
		return
	end

	if processing:is_processing() then
		responsemsg.errcode = EErrCode.ERR_DEADING_LASTREQ
		responsemsg.errcodedes = "正在处理上一次请求！"
		msghelper:send_resmsgto_client(fd, "RankListRes", responsemsg)		
		return
	end
	processing:set_process_state(false)
	responsemsg = msgproxy.sendrpc_reqmsgto_ranklistsvrd(request.rank_key, "get_ranklist_info", request)
	processing:set_process_state(false)

	if responsemsg == nil then
		responsemsg = {
			errcode = EErrCode.ERR_INVALID_REQUEST,
			errcodedes = "无效的请求!"
		}
	end

	msghelper:send_resmsgto_client(fd, "RankListRes", responsemsg)
end




return GetRankList